<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //任务二  李博 2020012314 10.23
    var arr = [
        {student_id:1,student_name:"张三",student_age:18,student_hobby:["唱歌","打篮球","画画"]},
        {student_id:2,student_name:"李四",student_age:19,student_hobby:["游泳","羽毛球","写字"]},
        {student_id:3,student_name:"王五",student_age:20,student_hobby:["唱歌","读书","乒乓球"]}
    ]
    var i=0,j=0,k=0;
    var tablewidth="500px";
    var tableheight="400px";
    document.write("<table border=1 width='"+ tablewidth +"' height='"+ tableheight +"' cellspacing='"+ 0 +"'>");
    function creatList(arr){
        var header = ["学号","姓名","年龄","爱好","操作"]
        for(j=0;j<5;j++){
            document.write("<th>");
            document.write(header[j]);
            document.write("</th>");
        }
        arr.forEach(function(e1,i,arr1){
            document.write("<tr>");
            for(j=0;j<5;j++){
                if(j==0){
                    document.write("<td style="+"text-align:center"+">");
                    document.write(arr[i].student_id);
                    document.write("</td>");
                }else if(j==1){
                    document.write("<td style="+"text-align:center"+">");
                    document.write(arr[i].student_name);
                    document.write("</td>");
                }else if(j==2){
                    document.write("<td style="+"text-align:center"+">");
                    document.write(arr[i].student_age);
                    document.write("</td>");
                }else if(j==3){
                    document.write("<td style="+"text-align:center"+">");
                    document.write(arr[i].student_hobby);
                    document.write("</td>");
                }else{
                    document.write("<td style="+"text-align:center"+">");
                    document.write("<a href="+"#"+">删除</a>");
                    document.write("</td>");
                }
            }
            document.write("</tr>");
        })
    }
    creatList(arr);
    document.write("</table>");
</script>
</html>